package cn.biplam.front.html;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.front.html.base.HtmlWindow;

/**
 * 	Html fieldset
 * @author XiaoRuxing
 * @version 1.0
 */
public class HtmlFieldSet extends HtmlWindow{
	
	private HtmlFieldSetLegend legend;

	public HtmlFieldSet(){}

	/**
	 * 构造方法
	 * @param ID 页面ID
	 */
	public HtmlFieldSet(String ID){
		super(ID);
	}

	/**
	 * 构造方法
	 * @param ID    页面ID
	 * @param cssID cssID
	 */
	public HtmlFieldSet(String ID,String cssID){
		super(ID,cssID);
	}

	public HtmlFieldSet(String ID,String cssID,String legendText) throws ErrorMessage{
		super(ID,cssID);
		this.legend = new HtmlFieldSetLegend(null,null,legendText);
		this.put(legend);
	}

	/**
	 * 设置上延边距
	 * @param value 
	 * @throws ErrorMessage
	 */
	public void setMarginTop(String value) throws ErrorMessage{
		this.legend.setMarginTop(value);
	}

	@Override
	protected void _getContent(StringBuilder sb) throws ErrorMessage {
	}

	/**
	 * 获取对象的Html形式
	 * @param sb
	 * @throws ErrorMessage
	 */
	@Override
	public void getHtml(StringBuilder sb) throws ErrorMessage {
		sb.append("<fieldset ");
		super.writeTagSetting(sb);
		sb.append(">\n");
		this.getContent(sb);
		sb.append("</fieldset>\n");
	}

	/**
	 * 复制对象
	 * @return 创建的新对象实例
	 * @throws ErrorMessage
	 */
	@Override
	public HtmlWindow copy() throws ErrorMessage {
		HtmlFieldSet htmlFieldSet = new HtmlFieldSet(this.getID(),this.getCssID());
		super._copy(htmlFieldSet);
		return htmlFieldSet;
	}

}
